package cn.tedu.ivoswork.dictoption.controller;

import cn.tedu.ivoswork.base.response.JsonResult;
import cn.tedu.ivoswork.dictoption.pojo.dto.DictOptionQuery;
import cn.tedu.ivoswork.dictoption.pojo.vo.DictOptionVO;
import cn.tedu.ivoswork.dictoption.service.IDictOptionService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Slf4j
@RestController
@RequestMapping("/v1/dictOption")
public class DictOptionController {
    @Autowired
    IDictOptionService dictOptionService;

    @GetMapping("select")
    public JsonResult select(DictOptionQuery dictOptionQuery){
        log.debug("加载字典项：参数={}",dictOptionQuery);
        List<DictOptionVO> list = dictOptionService.select(dictOptionQuery);
        return JsonResult.ok(list);
    }

    @GetMapping("select/{code}")
    public JsonResult select(@PathVariable String code){
        log.debug("根据code加载字典项：参数={}",code);
        List<DictOptionVO> list = dictOptionService.selectDictOptionByCode(code);
        return JsonResult.ok(list);
    }
}
